package com.aidex.framework.datasource;

import com.aidex.common.enums.DataSourceType;
import com.aidex.common.utils.StringUtils;

/**
 * @Author su
 * @Date 2023/3/27 14:28
 */
public class DataSourceUtils {
    public static void switchDataSource(String dataSource) {
        if (StringUtils.isNotEmpty(dataSource)) {
            //找出对应的枚举
            DataSourceType sourceType = DataSourceType.valueOf(dataSource);
            //手动切换数据源
            DynamicDataSourceContextHolder.setDataSourceType(sourceType.name());
        }
    }

    public static void clearDataSource() {
        //清空数据源变量
        DynamicDataSourceContextHolder.clearDataSourceType();
    }
}
